﻿using System.Windows.Controls;
using Store.WP7.Controls;
using Store.WP7.ViewModels;

namespace Store.WP7.Views
{
    public partial class ProductsView : StoreApplicationPage
    {
        //private ContinuumAnimation _flyOutAnimation = new ContinuumAnimation();
        private ProductsViewModel _viewModel;

        public ProductsView()
        {
            InitializeComponent();
            Loaded += (s, e) =>
            {
                //_flyOutAnimation.MasterItemFlyIn();
                _viewModel = ViewModelBase as ProductsViewModel;
            };
        }

        private void ProductsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //var productsList = sender as ListBox;
            //var selectedContainer = productsList.ItemContainerGenerator.ContainerFromItem(productsList.SelectedItem) as FrameworkElement;

            //if (selectedContainer != null)
            //{
            //    var exitAnimationElement = selectedContainer.Descendants()
            //                                .OfType<FrameworkElement>()
            //                                .SingleOrDefault(el => el.Name == "ProductTitle");

            //    //this._flyOutAnimation.MasterItemFlyOut(exitAnimationElement, () =>
            //    //    {
            //    //        _viewModel.SelectedProduct = productsList.SelectedItem as ProductViewModel;

            //    //        productsList.SelectedItem = null;
            //    //    });
            //}
        }
    }
}